<template>
	<router-view v-if="$route.meta.standAlone" />
	<router-view v-slot="{ Component, route }" v-else>
		<keep-alive>
			<component
				:is="Component"
				:key="getFirstLevelRoute(route).path"
				v-if="getFirstLevelRoute(route).meta.keepAlive"
			></component>
		</keep-alive>
		<component
			:is="Component"
			:key="getFirstLevelRoute(route).path"
			v-if="!getFirstLevelRoute(route).meta.keepAlive"
		></component>
	</router-view>
</template>

<script setup>
const getFirstLevelRoute = (route) => {
	if (!Array.isArray(route.matched) || route.matched.length === 0) {
		return route
	}
	return route.matched[0]
}
</script>

<style scoped></style>
